package inventory.daoImplementer;

import java.sql.SQLException;

import dbhandelling.Crude;
import dto.Gin;
import inventory.daoInterface.GinDao;

public class GinImplementor extends Crude implements GinDao
{
	
	@Override
	public void add(Gin gin) throws Exception 
	{
		insert(gin);
	}

	@Override
	public void update(Gin gin) throws Exception 
	{
		super.update("Gin","status" ,gin.getStatus()+"", "ginNo",gin.getGinNo()+"");
	}

	@Override
	public void delete(Gin gin) throws Exception 
	{
		super.delete("Gin","ginNo",gin.getGinNo()+"");
	}

	@Override
	public Gin retreive(String conditionField, String ConditionValue) throws Exception 
	{
		Gin gin=(Gin) super.retreive("Gin",conditionField, ConditionValue);
		return gin;
	}

	@Override
	public Gin[] retreiveArray(String conditionField, String conditionValue) throws Exception 
	{
		Gin[] gins;
		Object[] obj=super.retreiveArrayOnCondition("Gin", conditionField, conditionValue);
		gins=new Gin[obj.length];
		
		for(int i=0;i<gins.length;i++)
		{
			gins[i]=(Gin) obj[i];
		}
		
		return gins;
	}

	@Override
	public Gin[] retreiveAll() throws Exception 
	{
		Gin[] gins;
		
		Object[] obj=super.retreiveAll("Gin");
		
		gins=new Gin[obj.length];
		
		for(int i=0;i<gins.length;i++)
		{
			gins[i]=(Gin) obj[i];
		}
		
		return gins;
	}

}
